package controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import service.Book_Deal;

@WebServlet("/orderAdd")
public class orderAdd extends HttpServlet {
	private static final long serialVersionUID = 1L;
    private Book_Deal deal = new Book_Deal();
    public orderAdd() {
        super();
    }

	protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
		req.setCharacterEncoding("utf-8");
		res.setCharacterEncoding("utf-8");
		
		String id = req.getParameter("id");
		String book_id = req.getParameter("book_id");
		String book_price = req.getParameter("book_price");
		String number = req.getParameter("number");
		
		boolean falg = deal.book_add(id,book_id, book_price, number);
		if(falg) {
			res.sendRedirect("/TeachingTest/main?page=index&target=0");
		}else {
			res.sendRedirect("/TeachingTest/main?page=index&target=0");
		}
	}

	protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
		doGet(req,res);
	}

}
